package com.sx.zongzhi.presenter;

import android.content.Context;

import com.sx.zongzhi.bean.PhotoBean;
import com.sx.zongzhi.modle.ApiManager;
import com.sx.zongzhi.modle.HeadParamBean;
import com.sx.zongzhi.net.BaseCallBack;
import com.sx.zongzhi.net.BaseResult;
import com.sx.zongzhi.view.UploadFileView;

import java.io.File;
import java.util.List;
import java.util.Map;

/**
 * @desc: 上传文件的presenter
 */

public class UploadFilePest{

    private UploadFileView uploadView;

    public UploadFilePest(UploadFileView uploadView) {
        this.uploadView = uploadView;
    }

    public void uploadFile(Context context,List<File> files) {
        Map<String,Object> map = HeadParamBean.getHead(context);
        ApiManager.upLoadMultiFile(map,files, new BaseCallBack<BaseResult<List<PhotoBean>>>() {
            @Override
            public void onSuccess(BaseResult<List<PhotoBean>> response) {
                uploadView.uploadSuccess(response.getData());
            }

            @Override
            public void onFailures(String message) {
                uploadView.showError(message);
            }
        });
    }
}

